<?php
/**
 * class ProductView
 *  
 */
class ProductView {

    public static function getProduct($data) {
        return'<div class="span5">
                <h3>' . $data['name'] . '</h3>
                <table class="table">
                    <tr><td>Рубрика</td><td>' . $data['rubric'] . '</td></tr>
                    <tr><td>Организация</td><td>' . $data['owner'] . '</td></tr>
                    <tr><td>Город</td><td>' . $data['cityfrom'] . '</td></tr>
                    <tr><td>Цена</td><td><h4>' . $data['price'] . '$</h4></td></tr>
                </table>
                <hr>
            </div>';
    }

    public static function getPoducts($data) {
        $out = '';
        $out.='<div class="span5">';

        if (!empty($data['company_id'])) {
            $out.='<div class="edit_button">
             <a href="' . HTTP_SERVER . 'Product/add/' . $data['company_id'] . '" class="btn btn-primary">Добавить продукт</a>
             </div>';
        }

        if (count($data['rows']) > 0) {
            foreach ($data['rows'] as $row) {
                $out.='
            <div class="product">
                <h3><a href="' . HTTP_SERVER . 'Product/show/' . $row['product_id'] . '">' . $row['name'] . '</a></h3>
                <table class="table">
                    <tr><td>Рубрика</td><td>' . $row['rubric'] . '</td></tr>
                    <tr><td>Организация</td><td>' . $row['owner'] . '</td></tr>
                    <tr><td>Город</td><td>' . $row['cityfrom'] . '</td></tr>
                    <tr><td>Цена</td><td><h4>' . $row['price'] . '$</h4></td></tr>
                </table>
                <hr>
            </div>
';
            }
        } else {
            $out.='Нет товаров';
        }
        $out.='</div>';
        return $out;
    }

    public static function getAddProductForm($company_id, $owner) {
        return'<div class="span6">
            <form method="POST" action="' . HTTP_SERVER . 'Product/add/' . $company_id . '" class="form-horizontal">
                <fieldset>
                    <div class="control-group"><label class="control-label">Название товара</label><div class="controls"><input name="name" type="text" class="span3"></div></div>
                    <div class="control-group"><label class="control-label">Рубрика</label><div class="controls"><select name="rubric" class="span3"><option value="0">какая-то рубрика</option></select></div></div>
                    <div class="control-group"><label class="control-label">Город</label><div class="controls"><input name="cityfrom" type="text" class="span3"></div></div>
                    <div class="control-group"><label class="control-label">Цена</label><div class="controls"><input name="price" type="text" class="span3"></div></div>
                    <div class="form-actions"><input name="submit" type="submit" value="Создать товар" class="btn btn-primary"></div>
                </fieldset>
                <input type="hidden" name="owner" value="' . $owner . '">
            </form>
        </div>';
    }

}

?>